package com.code.day17;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

public class Demo17Iterator {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("唐僧");
        list.add("孙悟空");
        list.add("猪八戒");
        list.add("沙和尚");

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            if ("猪八戒".equals(s)) {
                list.add("白龙马");
            }
        }
        System.out.println(Arrays.toString(list.toArray()));

        int[] str = {1, 2, 3, 4, 5};
        int[] ints = Arrays.copyOf(str, str.length + 5);
        System.out.println(ints);
        System.out.println(Arrays.toString(ints));
    }

}
